package com.github.edu.repair.manager.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 报修申请，物料使用情况
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-20
 */
@Entity
@Table(name = "t_bx_bxsq_wlxx")
public class TBxBxsqWlxx implements Serializable {
    private Integer id;
    private Integer mc;//tbxWLK 物料名称
    private Integer wxfs;//维修方式
    private Integer fl;//物料分类 tbxWlfl
    private Integer sysl;//使用数量
    private Integer gs;//工时
    private Integer gsf;//工时费
    private Integer clf;//材料费
    private Integer hj;//合计
    private String bz;//备注
    private Integer tBxBxsqId;//关联申请单
    private TBxWlfl wlfl;//物料分类情况
    private TBxWlk wlk;//物料
    private String wlmc;//物料名称
    private String flmc;//分类名称
    private String sssq;//所属申请
    private TBxBxsq bxBxsq;//所属报修

    @Id
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "mc")
    public Integer getMc() {
        return mc;
    }

    public void setMc(Integer mc) {
        this.mc = mc;
    }

    @Basic
    @Column(name = "wxfs")
    public Integer getWxfs() {
        return wxfs;
    }

    public void setWxfs(Integer wxfs) {
        this.wxfs = wxfs;
    }

    @Basic
    @Column(name = "fl")
    public Integer getFl() {
        return fl;
    }

    public void setFl(Integer fl) {
        this.fl = fl;
    }

    @Basic
    @Column(name = "sysl")
    public Integer getSysl() {
        return sysl;
    }

    public void setSysl(Integer sysl) {
        this.sysl = sysl;
    }

    @Basic
    @Column(name = "gs")
    public Integer getGs() {
        return gs;
    }

    public void setGs(Integer gs) {
        this.gs = gs;
    }

    @Basic
    @Column(name = "gsf")
    public Integer getGsf() {
        return gsf;
    }

    public void setGsf(Integer gsf) {
        this.gsf = gsf;
    }

    @Basic
    @Column(name = "clf")
    public Integer getClf() {
        return clf;
    }

    public void setClf(Integer clf) {
        this.clf = clf;
    }

    @Basic
    @Column(name = "hj")
    public Integer getHj() {
        return hj;
    }

    public void setHj(Integer hj) {
        this.hj = hj;
    }

    @Basic
    @Column(name = "bz")
    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    @Basic
    @Column(name = "t_bx_bxsq_id")
    public Integer gettBxBxsqId() {
        return tBxBxsqId;
    }

    public void settBxBxsqId(Integer tBxBxsqId) {
        this.tBxBxsqId = tBxBxsqId;
    }

    @ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name = "fl",referencedColumnName = "id",updatable = false,insertable = false)
    public TBxWlfl getWlfl() {
        return wlfl;
    }

    public void setWlfl(TBxWlfl wlfl) {
        if(null!=wlfl){
            this.flmc=wlfl.getMc();
        }
        this.wlfl = wlfl;
    }

    @ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name = "mc",referencedColumnName = "id",updatable = false,insertable = false)
    public TBxWlk getWlk() {
        return wlk;
    }

    public void setWlk(TBxWlk wlk) {
        if(null!=wlk){
            this.wlmc=wlk.getName();
        }
        this.wlk = wlk;
    }


    @ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name = "t_bx_bxsq_id",referencedColumnName = "id",updatable = false,insertable = false)
    public TBxBxsq getBxBxsq() {
        return bxBxsq;
    }

    public void setBxBxsq(TBxBxsq bxBxsq) {
        if(null!=bxBxsq){
            this.sssq=bxBxsq.getLcmc();
        }
        this.bxBxsq = bxBxsq;
    }

    @Transient
    public String getWlmc() {
        return wlmc;
    }

    public void setWlmc(String wlmc) {
        this.wlmc = wlmc;
    }
    @Transient
    public String getFlmc() {
        return flmc;
    }

    public void setFlmc(String flmc) {
        this.flmc = flmc;
    }

    @Transient
    public String getSssq() {
        return sssq;
    }

    public void setSssq(String sssq) {
        this.sssq = sssq;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TBxBxsqWlxx that = (TBxBxsqWlxx) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(mc, that.mc) &&
                Objects.equals(wxfs, that.wxfs) &&
                Objects.equals(fl, that.fl) &&
                Objects.equals(sysl, that.sysl) &&
                Objects.equals(gs, that.gs) &&
                Objects.equals(gsf, that.gsf) &&
                Objects.equals(clf, that.clf) &&
                Objects.equals(hj, that.hj) &&
                Objects.equals(bz, that.bz) &&
                Objects.equals(tBxBxsqId, that.tBxBxsqId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, mc, wxfs, fl, sysl, gs, gsf, clf, hj, bz, tBxBxsqId);
    }
}
